﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

using JohnnySins.DAL;
using JohnnySins.DAL.Repositories;
using JohnnySins.Entities;
using JohnnySins.Code;

namespace JohnnySins
{
    public partial class AboutMe : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                LoadData();
            }
        }

        public void LoadData()
        {
            using (var repo = RepositoryFactory.ResolveRepository<ParameterSiteRepository>())
            {
                txtEthnicity.Text = "";
                ParameterSite itm = repo.Find("AboutMe_Ethnicity");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtEthnicity.Text = itm.ParameterValueStr;

                txtCountryOfOrigin.Text = "";
                itm = repo.Find("AboutMe_CountryOfOrigin");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtCountryOfOrigin.Text = itm.ParameterValueStr;

                txtState.Text = "";
                itm = repo.Find("AboutMe_State");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtState.Text = itm.ParameterValueStr;

                txtPlaceOfBirth.Text = "";
                itm = repo.Find("AboutMe_PlaceOfBirth");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtPlaceOfBirth.Text = itm.ParameterValueStr;

                txtCity.Text = "";
                itm = repo.Find("AboutMe_City");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtCity.Text = itm.ParameterValueStr;

                txtDateOfBirth.Text = "";
                itm = repo.Find("AboutMe_DateOfBirth");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtDateOfBirth.Text = itm.ParameterValueStr;

                txtEyeColor.Text = "";
                itm = repo.Find("AboutMe_EyeColor");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtEyeColor.Text = itm.ParameterValueStr;

                txtHairColor.Text = "";
                itm = repo.Find("AboutMe_HairColor");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtHairColor.Text = itm.ParameterValueStr;

                txtHeight.Text = "";
                itm = repo.Find("AboutMe_Height");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtHeight.Text = itm.ParameterValueStr;

                txtWeight.Text = "";
                itm = repo.Find("AboutMe_Weight");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtWeight.Text = itm.ParameterValueStr;

                txtMyTwitter.Text = "";
                itm = repo.Find("AboutMe_MyTwitter");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtMyTwitter.Text = itm.ParameterValueStr;

                txtWebsiteTwitter.Text = "";
                itm = repo.Find("AboutMe_WebsiteTwitter");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtWebsiteTwitter.Text = itm.ParameterValueStr;

                txtAboutMe.Text = "";
                itm = repo.Find("AboutMe");
                if ((itm != null) && (!string.IsNullOrEmpty(itm.ParameterValueStr)))
                    txtAboutMe.Text = itm.ParameterValueStr.Replace("\n", "<br/>");
            }
        }
    }
}